﻿using System;

namespace OpenCompiler.Scanning.Tests
{
	public class NewlineTestRunner
	{
		public static string[] NewlineDefinitions = new[]
		                                            	{
		                                            		"\n",
		                                            		"\n\r"
		                                            	};

		/// <summary>
		/// Execute an action with a string parameter that has been
		/// formatted with the different newline definitions supported
		/// </summary>
		/// <param name="source">The source to format - parameter 0 ({0}) will be the newline</param>
		/// <param name="action">Action to execute with one parameter - the formatted string</param>
		/// <remarks>
		/// Uses string formatting with parameter {0} to insert the newline definitions
		/// </remarks>
		public static void RunAllDefinitions(string source, Action<string> action)
		{
			foreach( var newline in NewlineDefinitions )
			{
				var formattedSource = string.Format(source, newline);
				action(formattedSource);
			}
		}
	}
}